﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RelationExpertSystem.Relation
{
    public class Parent_In_Law : RelationBase
    {
        private static Parent_In_Law _singleton = new Parent_In_Law();
        public static Parent_In_Law Instance
        {
            get { return _singleton; }
        }

        private Parent_In_Law() { }

        public override bool IsRelated(Person a, Person b)
        {
            // b = Rosario
            // a = Rich
            // b is a's Parent_In_Law IFF b is a's spouse's parent AND b is NOT a's parent
            return !Person.IsNull(a.Spouse) && a.Spouse.KnownRelation(Parent.Instance, b) &&
                !(a.Mother == b || a.Father == b);
        }

        public override IEnumerable<IRelation> GetDependencies()
        {
            return new HashSet<IRelation>(new IRelation[] {
                Spouse.Instance, Parent.Instance, Mother.Instance, Father.Instance });
        }
    }
}
